﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;


namespace Sole
{
    public class Projectile : Entity
    {
        public Projectile(SpriteBatch spritebatch, Game game)
            : base(spritebatch, game)
        {
        }

        public override void Initialize()
        {
            speed = 0.8f;
            velocity.X = 0.1f;
            base.Initialize();
        }

        protected override void LoadContent()
        {
            texture = Game.Content.Load<Texture2D>(@"Images//AvatarProjectilesTest_25x15");
            origin = new Vector2(0.0f, (float)texture.Height * 0.5f);
            screenBoundaries = new Rectangle(0, 0,
                Game.Window.ClientBounds.Width,
                Game.Window.ClientBounds.Height);

            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            if (position.X - texture.Width > screenBoundaries.Width)
            {
                killMe = true;
            }
            else if (position.X + texture.Width < screenBoundaries.X)
            {
                killMe = true;
            }

            if (position.Y - texture.Height > screenBoundaries.Height)
            {
                killMe = true;
            }
            else if (position.Y + texture.Height < screenBoundaries.Y)
            {
                killMe = true;
            }

            position += velocity * speed * (float)gameTime.ElapsedGameTime.Milliseconds; //velocity * speed * (float)gameTime.ElapsedGameTime.Milliseconds;
        }

        public override void OnCollision() //kan ta in parameter med entitet den krockar med för att bestämma utgång (skada, fortsätta etc.)
        {
            killMe = true;
        }


    }
}
